package edu.cmu.cs.webapp.ioms.ui.wizards.order;

import org.eclipse.jface.wizard.Wizard;

import edu.cmu.cs.webapp.ioms.models.Client;
import edu.cmu.cs.webapp.ioms.models.impl.IOMSFactoryImpl;

/**
 * 
 * @author Christian
 */
public class CustomerWizard extends Wizard {
	private CustomerWizardPage _generalPage;
	private boolean _isUpdate;
	private Client _model;

	public CustomerWizard(boolean update, Client model) {
		_isUpdate = update;
		this._model = model;
	}

	@Override
	public void addPages() {
		_generalPage = new CustomerWizardPage("General Page");
		addPage(_generalPage);
	}

	@Override
	public boolean performFinish() {
		if (_model == null) {
			_model = IOMSFactoryImpl.eINSTANCE.createClient();
		}
		
		_model.setFname(_generalPage.getFname());
		_model.setLname(_generalPage.getLname());
		_model.setAddress(_generalPage.getAddress());
		_model.setPhone(_generalPage.getPhone());
		_model.setEmail(_generalPage.getEmail());
		_model.setCompany(_generalPage.getCompany());
		_model.setCity(_generalPage.getCity());
		_model.setState(_generalPage.getState());
		_model.setCountry(_generalPage.getCountry());
		
		return true;
	}

	public Client getModel() {
		return this._model;
	}

	public boolean isUpdate() {
		return _isUpdate;
	}

}
